<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="/favicon.ico">
    <link rel="Shortcut Icon" href="/favicon.ico" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="../lib/html5shiv.js"></script>
    <script type="text/javascript" src="../lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="../lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <!--/meta 作为公共模版分离出去-->

    <title>配置编辑查看</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

</head>

<body>
    <article class="page-container">
        <form class="form form-horizontal" id="form-article-add">

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>ID标识：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="0" placeholder="" name="id" readonly>
                </div>
            </div>


            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>构建文件</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value=""
                        placeholder="集群主模式：netcore.sh 集群子模式：sun.sh 单版本模式：single.sh" name="shellBuildFile">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">回滚文件</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="netcoreback.sh" placeholder="netcoreback.sh"
                        title="回滚后要重新构建，回归是把旧版本文件复制到构建文件夹中" name="shellBackFile">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>容器端口</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="number" class="input-text" style="width:250px;" value=""
                        placeholder="0表示不构建123不排重nginx专用" name="openPort">
                </div>
            </div>

            <div class="row cl styleadd">
                <label class="form-label col-xs-4 col-sm-2">其他端口</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" title="上面也是子端口" placeholder="1200,13101,1200-1230"
                        name="portStrs">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>容器名称</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" title="容器名称或者待替换的nginx配置文件名称"
                        placeholder="dockercontainer或者project.conf(/workdir/nginx/project/project.conf)"
                        name="containerName">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目信息</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <span class="select-box">
                        <select name="jobInfoId" class="select">
                            <option value="0">错误请刷新</option>
                        </select>
                    </span>
                    <input type="button" class="btnselect" value="选择"
                        onclick="_showedit('选择用户','../jobinfo/selectjobinfo.html','','90%','100%')">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>执行服务器</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <span class="select-box">
                        <select name="serverInfoId" class="select">
                            <option value="0">错误请刷新</option>
                        </select>
                    </span>
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">子模式</label>
                <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                    <div class="check-box">
                        <input type="checkbox" name="boolIsSun" title="子模式配置文件为sun.sh 不可回滚" value="">
                        <label for="checkbox-pinglun">子模式不可回滚，子模式的配置文件为sun.sh 子模式直接docker run ！</label>
                    </div>
                </div>
            </div>



            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">排序</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="number" class="input-text" value="100" placeholder="" name="sortIndex">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">补充信息</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" title="docker启动参数或者是nginx的配置完整路径"
                        placeholder="-v%20/app/xxx:/app/xxx或/etc/nginx/conf.d/tycenter.conf" name="otherargs">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">项目存放</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" title="一般用于非执行的，比如静态网站"
                        placeholder="一般用于非执行的，比如静态网站/xxx/xxx/xxx/xxx" name="fullPath">
                </div>
            </div>

            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-sm-offset-2">
                    <button onClick="_funcAdd();" class="btn btn-primary radius" type="button">保存</button>
                    <!--<button onClick="article_save();" class="btn btn-secondary radius" type="button"><i class="Hui-iconfont">&#xe632;</i> 保存草稿</button>-->

                </div>
            </div>
        </form>
    </article>

    <!--_footer 作为公共模版分离出去-->
    <script type="text/javascript" src="../lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="../lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="../static/h-ui/js/H-ui.min.js"></script>
    <script type="text/javascript" src="../static/h-ui.admin/js/H-ui.admin.js"></script>
    <!--/_footer /作为公共模版分离出去-->
    <!--请在下方写此页面业务相关的脚本-->
    <!-- <script type="text/javascript" src="../lib/My97DatePicker/4.8/WdatePicker.js"></script> -->
    <!--<script type="text/javascript" src="../lib/jquery.validation/1.14.0/jquery.validate.js"></script>-->
    <!--<script type="text/javascript" src="../lib/jquery.validation/1.14.0/validate-methods.js"></script>-->
    <!--<script type="text/javascript" src="../lib/jquery.validation/1.14.0/messages_zh.js"></script>-->
    <!--<script type="text/javascript" src="../lib/webuploader/0.1.5/webuploader.min.js"></script>-->
    <!--<script type="text/javascript" src="../libueditor/1.4.3/ueditor.config.js"></script>-->
    <!--<script type="text/javascript" src="../libueditor/1.4.3/ueditor.all.min.js"></script>-->
    <!--<script type="text/javascript" src="../libueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>-->
    <script src="../lib/api.js"></script>


    <script type="text/javascript">

        var iseditemodel = false;
        $(function () {


            //获取参数中的ID
            var userid = 0;

            var uidstr = _apigetquery("id");
            if (uidstr != null) {
                userid = parseInt(uidstr);
                iseditemodel = true;
                if (userid == 0) {
                    iseditemodel = false;
                }
            } else {

                iseditemodel = false;

            }



            //读取项目信息
            _apiget("/api/spider/jobInfo?page=1&size=2000", false, function (code, obj) {
                $("[name=jobInfoId]").empty();
                if (code == 200) {

                    var datas = obj.items;
                    var htmlStr = "";
                    for (var k = 0; k < datas.length; k++) {
                        var item = datas[k];
                        htmlStr += '<option value="' + item.id + '">' + item.projectDisplayName + '</option>';
                    }
                    $("[name=jobInfoId]").append(htmlStr);

                }
            });

            //读取执行者信息
            _apiget("/api/spider/joberInfo?page=1&size=2000", false, function (code, obj) {
                $("[name=serverInfoId]").empty();
                if (code == 200) {

                    var datas = obj.items;
                    var htmlStr = "";
                    for (var k = 0; k < datas.length; k++) {
                        var item = datas[k];
                        htmlStr += '<option value="' + item.id + '">' + item.joberName + '</option>';
                    }
                    $("[name=serverInfoId]").append(htmlStr);

                }
            });



            if (iseditemodel) {

                $(".styleadd").hide();

                _loaditem(userid);
            }

        });

        function _loaditem(userid) {
            //读取角色列表
            _apiget("/api/spider/jobConfig/" + userid + "/infoForUpdate", true, function (code, obj) {
                if (code == 200) {
                    for (var key in obj) {
                        var objdom = $("[name=" + key + "]");
                        if (objdom.length > 0) {
                            var tagname = objdom[0].tagName;
                            if (tagname == "INPUT") {
                                var type = objdom[0].type;
                                if (type == "checkbox") {
                                    console.log(obj[key]);
                                    if (obj[key] || obj[key] === 1) {
                                        objdom.prop("checked", true);
                                        objdom.parent().addClass("checked");
                                    }else{
                                        objdom.prop("checked", false);
                                        objdom.parent().removeClass("checked");
                                    }
                                } else {
                                    objdom.val(obj[key]);
                                }
                            } else if (tagname == "SELECT") {
                                objdom.val(obj[key]);
                            }
                        }
                    }

                }
            });


        }

        function _setjobinfoid(id, title) {

            $("select[name=jobInfoId]").val(id);
        }

        function _funcAdd() {

            if (iseditemodel) {
                
                var dataobj = $("#form-article-add").parseForm();
                _apipost("/api/spider/jobConfig/updateItem", true, JSON.stringify(dataobj), function (code, obj) {
                    if (code == 200) {
                        layer.msg("更新成功", { time: 1500 }, function () {
                            if (removeIframe) {
                                removeIframe();
                            }
                        });

                    }
                });
            } else {

                var dataobj = $("#form-article-add").parseForm();
                _apipost("/api/spider/jobConfig/item", true, JSON.stringify(dataobj), function (code, obj) {
                    if (code == 200) {
                        layer.msg("添加成功");
                    }
                });

            }
        }
    </script>
    <!--/请在上方写此页面业务相关的脚本-->
</body>

</html>